package com.ruiya.staging.goods.cas.client;

import com.ruiya.staging.goods.locate.grpc.GetGoodsIdRequest;
import com.ruiya.staging.goods.locate.grpc.GetGoodsIdResponse;
import com.ruiya.staging.goods.locate.grpc.LocateIOServiceGrpc;
import net.devh.boot.grpc.client.inject.GrpcClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class LocateIOClient {
    private static final Logger _log = LoggerFactory.getLogger(LocateIOClient.class);

    @GrpcClient("goods-locate")
    private LocateIOServiceGrpc.LocateIOServiceBlockingStub locateIOServiceStub;


    public GetGoodsIdResponse getGoodsId(GetGoodsIdRequest request){
        _log.info("getGoodsId. tid={}, goodsNo={}", request.getTid(), request.getGoodsNo());
        GetGoodsIdResponse response = this.locateIOServiceStub.getGoodsId(request);
        _log.info("getGoodsId. tid={}, code={}", request.getTid(), response.getStatus().getCode());
        return response;
    }

}
